var mUtil={
	tabs:function tabs(tabTit, select, tabCon) {
		$(tabCon).children().eq(0).show();
		var timer = null;
		clearTimeout(timer);
		$(tabTit).children().hover(function() {
			var index = $(tabTit).children().index(this);
			var that = $(this);
			console.log(that);
			timer = setTimeout(function() {
				that.addClass(select).siblings().removeClass(select);
				$(tabCon).children().eq(index).stop().fadeIn().siblings().hide();
			}, 200)
		}, function() {
			clearTimeout(timer);
		});
	},
	getDate:function(){
		var date=new Date().getFullYear();
		return date;
	},
	validate:{
		toast:function(_this,str){
			layer.msg(str, function(){
				    _this.focus();
				});
		},
		notNull:function(_this,str){
			if(_this.val()==""){
				this.toast(_this,str);
				return false;
			}else{
				return true;
			}
		},
		phone:function(_this,str){
			var reg=/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/;
			if(!reg.test(_this.val())){
				this.toast(_this,str);
				return false;
			}else{
				return true;
			}
		}
	}
}

$(function(){
	$(".cur-year").text(mUtil.getDate());
	
	var $submit=$("#submit");
	$submit.on("click",function(){
		var checkName=mUtil.validate.notNull($(".username"),"请填入您的姓名");
		var checkPhone=mUtil.validate.notNull($(".phonenum"),"请填入您的电话或者手机号码") && mUtil.validate.phone($(".phonenum"),"请填入正确的电话或者手机号码"),
			$that=$(this);
		if(checkName && checkPhone){
			$that.attr("disabled",true);
			$.ajax({
				type:"post",
				url:"",
				async:true,
				data:$(".customer-info").serialize(),
				dataType:'json',
				success:function(){
					
				},
				error:function(){
					layer.msg('提交信息失败，请检查网络后重试。', {icon: 5});
					$that.attr("disabled",false);
				}
			});
		}
	})
})
